<template>

	<section>
		<el-row>
			<el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
				<el-form :inline="true" >
					<el-form-item>
						<el-button type="primary" @click="staticHome">生成首页静态页面</el-button>
					</el-form-item>
				</el-form>
			</el-col>
		</el-row>

		<el-row>

			<el-col class="left-conainer" :span="8">
				<!--树-->
				<el-tree :data="productTypes" :props="defaultProps" @node-click="handleNodeClick"></el-tree>
			</el-col>
			<el-col class="righter-conainer" :span="16">

			</el-col>
		</el-row>
	</section>
</template>

<script>
    export default {
        data() {
            return {
                productTypes: [],
                defaultProps: {
                    children: 'children',
                    label: 'name'
                }
            };
        },
        methods: {
            handleNodeClick(data) {
                console.log(data);
            },
			//加载类型数据
			loadProductType(){
				this.$http.get("/product/productType/list")
					.then(res=>{
					    let data = res.data;
					    this.productTypes = data;
					})
			},//显示新增界面
            staticHome: function () {
                alert("???????????????")
                this.$confirm('确认生成吗？', '提示', {}).then(() => {
                    this.editLoading = true;
                    this.$http.post("/product/productType/getHomePage")
                        .then(res=>{
                            this.editLoading = false;
                            if(data.success){
                                this.$message({
                                    message: '生成完毕',
                                    type: 'success'
                                });
                            }else{
                                this.$message({
                                    message: data.message,
                                    type: 'error'
                                });
                            }
                        })

                });
            },
        },
		mounted(){
            this.loadProductType();
		}
    };

</script>

<style scoped>
	.left-conainer{
		height: 500px;
		border:1px solid #d9d9d9;
	}
	.righter-conainer{
		height: 500px;
		border:1px solid #d9d9d9;
		border-left:none
	}
</style>